﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string[] str = Directory.GetFiles(@"C:\Users\Administrator\Desktop\thum");
            foreach (string s in str)
            {
                string f = @"C:\Users\Administrator\Desktop\thum\thumb\" + Path.GetFileName(s);
                FasterThumb(s, f, 100, 100);
            }
        }

        /// <summary>
        /// 快速缩略图
        /// </summary>
        /// <param name="originalImagePath"></param>
        /// <param name="thumbPath"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public static void FasterThumb(string originalImagePath, string thumbPath, int width, int height)
        {
            System.Drawing.Image originalImage = System.Drawing.Image.FromFile(originalImagePath);
            Image img = originalImage.GetThumbnailImage(width, height, null, IntPtr.Zero);
            img.Save(thumbPath);
        }
    }
}
